package com.hitplane.attack 
{
	import com.hitplane.core.Bullet;
	import com.hitplane.core.Fly;
	import com.hitplane.interfaces.IAttack;
	import com.hitplane.manager.GameContainManager;
	import com.hitplane.manager.ObjectPoolManager;
	
	/**
	 * @describe  	普通攻击
	 * 				子弹直射攻击
	 * @author  	郑子华
	 * @website 	http://blog.sina.com.cn/zihua2007
	 * @time		... 
	 */
	public class NormalBulletAttack implements IAttack
	{
		//子弹类
		private var _bulletClass:Class;
		//发射子弹的载体	
		private var _supporter:Fly;
		//子弹攻击方向
		private var _dirX:int;
		private var _dirY:int;
		
		public function NormalBulletAttack(supporter:Fly,bulletClass:Class,dirX:int=1,dirY:int=1) 
		{
			_supporter = supporter;
			_bulletClass = bulletClass;
			_dirX=dirX;
			_dirY=dirY;
		}
		
		/* INTERFACE com.hitplane.interfaces.IAttack */
		
		public function action():void
		{
			//创建子弹
			var bullet:Bullet=ObjectPoolManager.instance.getObjByClass(_bulletClass) as Bullet;
			//提供子弹的初始速度,放置到对应容器
			bullet.vx = 0*_dirX;
			bullet.vy = 10*_dirY;
			//设定子弹类型
			bullet.type = _attackType;
			bullet.x = _supporter.x;
			bullet.y = _supporter.y;
			GameContainManager.instance.gameContain.addChild(bullet);
		}
		private var _attackType:String;
		public function set attackType(value:String):void {
			_attackType = value;
		}
		public function get attackType():String {
			return _attackType;
		}
		
	}
	
}